﻿@model Order
@using (Html.BeginForm())
{
    <div class="modal-body">
        @if (Model != null)
        {
            <div>
                @if (Model.Status == OrderStatus.Pending || Model.Status == OrderStatus.WaitBuyerPay)
                {
                    <p>
                        留言信息：<textarea name="message" cols="50" rows="3" maxlength="100" style="width: 450px;">@(Model.BuyerMessage)</textarea></p>
                    <p class="help-block">
                        留言信息作为你对这笔订单的备忘记录，仅自己可见。请勿备注个人敏感信息。<span class="color-red">（<200字）</span>
                    </p>
                }
                else
                {
                    <p>
                        该订单当前状态不可修改留言信息！
                    </p>
                }
            </div>
        }
        else
        {
            <div>
                <div class="status-box status-box-warm-error">
                    <div class="status-icon">
                        <div class="row-fluid">
                            <div class="span2">
                                <i class="icon-remove-sign icon-3x"></i>
                            </div>
                            <div class="span10">
                                <strong>登录超时或订单不存在！</strong></div>
                        </div>
                    </div>
                </div>
            </div>
        }
    </div>
    <div class="modal-footer">
        <p id="message" class="pull-left color-red">
        </p>
        <a class="btn" href="#" data-dismiss="modal">关闭</a>
        @if (Model != null && (Model.Status == OrderStatus.Pending || Model.Status == OrderStatus.WaitBuyerPay))
        {
            <button type="button" class="btn btn-primary" onclick="submitForm(this.form)">
                确 认</button>
        }
    </div>
}
<script type="text/javascript">
    function submitForm(form) {
        var param = $(form).serialize();
        $.postJSON(form.action, param, function (result) {
            if (result.Status == false) {
                $('#message', form).css('color', 'red').html(result.Message);
            }
            else {
                $('#message', form).css('color', 'green').html("留言信息已成功保存！");
            }
        });
    }
</script>
